package com.peter.custom_linear;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Pair;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    static int count = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button button = findViewById(R.id.bt);

        LinearLayout linearLayout = findViewById(R.id.linearLayout);

        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                System.out.println("---------------------------------------------");

                TextView textView = new TextView(MainActivity.this);
                textView.setText("Fucked up" + count);
                count++;

                linearLayout.addView(textView);

                int c = linearLayout.getChildCount();

                for (int i = 0; i < c; ++i) {
                    TextView otherChild = (TextView) linearLayout.getChildAt(i);

                    otherChild.setText("a1" + otherChild.getText());

                }

            }
        });
    }


}